﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DTN.Core;
using Hanel.DTN.News;

public partial class Control_Home_panelXaHoi : System.Web.UI.UserControl
{
    ItblContentManager obj = tblContentManager.CreateInstance();
    ItblOS_Crawer_ChannelsManager objChannel = tblOS_Crawer_ChannelsManager.CreateInstance();
    protected void Page_Load(object sender, EventArgs e)
    {
        DisplayOToXeMay();
        DisplayDoiSong();
        DisplayPhapLuat();
        DisplayKhoaHoc();
        DisplayViTinh();
    }
    protected void DisplayOToXeMay()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 1", "Status=1 and ChannelID=90", "ID_Content desc");
        int id = int.Parse(dt.Rows[0]["ID"].ToString());
        DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=90 and id<>" + id, "ID_Content desc");

        DataList1.DataSource = dt;
        DataList1.DataBind();
        DataList2.DataSource = dt2;
        DataList2.DataBind();
    }

    protected void DisplayDoiSong()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 1", "Status=1 and ChannelID=80", "ID_Content desc");
        int id = int.Parse(dt.Rows[0]["ID"].ToString());
        DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=80 and id<>" + id, "ID_Content desc");

        DataList3.DataSource = dt;
        DataList3.DataBind();
        DataList4.DataSource = dt2;
        DataList4.DataBind();
    }

    protected void DisplayPhapLuat()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 1", "Status=1 and ChannelID=78", "ID_Content desc");
        int id = int.Parse(dt.Rows[0]["ID"].ToString());
        DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=78 and id<>" + id, "ID_Content desc");

        DataList5.DataSource = dt;
        DataList5.DataBind();
        DataList6.DataSource = dt2;
        DataList6.DataBind();
    }

    protected void DisplayKhoaHoc()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 1", "Status=1 and ChannelID=83", "ID_Content desc");
        int id = int.Parse(dt.Rows[0]["ID"].ToString());
        DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=83 and id<>" + id, "ID_Content desc");

        DataList7.DataSource = dt;
        DataList7.DataBind();
        DataList8.DataSource = dt2;
        DataList8.DataBind();
    }

    protected void DisplayViTinh()
    {
        
        DataTable dt = obj.SelecttblContentDynamic_top("Top 4", "Status=1 and ChannelID=86", "ID_Content desc");
        //int id = int.Parse(dt.Rows[0]["ID"].ToString());
        //DataTable dt2 = obj.SelecttblContentDynamic_top("Top 2", "Status=1 and ChannelID=86 and id<>" + id, "DatePage desc");

        DataList9.DataSource = dt;
        DataList9.DataBind();
        //DataList10.DataSource = dt2;
        //DataList10.DataBind();
    }

    public string BindMenuOToXeMay()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 90", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">" + dr["Name"] + "</a>";
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }

        }
        catch
        {
            return data;
        }
        return data;
    }

    public string BindMenuDoiSong()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 80", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">" + dr["Name"] + "</a>";
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }

        }
        catch
        {
            return data;
        }
        return data;
    }
    public string BindMenuPhapLuat()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 78", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">" + dr["Name"] + "</a>";
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }

        }
        catch
        {
            return data;
        }
        return data;
    }
    public string BindMenuKhoaHoc()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 83", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">" + dr["Name"] + "</a>";
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }

        }
        catch
        {
            return data;
        }
        return data;
    }
    public string BindMenuViTinh()
    {
        string data = string.Empty;
        try
        {

            DataTable dt = objChannel.SelectOS_Crawer_ChannelsDynamic("ParentID= 86", "ID desc");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dt.Rows[i];
                data += "<li><a href=\"News.aspx?channel=" + dr["ID"] + "\">" + dr["Name"] + "</a>";
                data += "</li>";
                if (i == (dt.Rows.Count - 1))
                {
                    data += "<li></li>";
                }
                else
                {
                    data += "<li>•</li>";
                }
            }

        }
        catch
        {
            return data;
        }
        return data;
    }
}